﻿using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Auth.Application.IServices.Base;
using Auth.Dtos.Base;
using Auth.Models;
using Auth.Models.Base;
using Microsoft.AspNetCore.Mvc;

namespace Auth.Web.Api.Apis.Base
{
    /// <summary>
    /// 声明类型接口
    /// </summary>
    public class ClaimTypeController : ApiController
    {
        /// <summary>
        /// 服务接口
        /// </summary>
        private readonly IClaimTypeService _service;

        /// <summary>
        /// Constructor
        /// </summary>
        public ClaimTypeController(IClaimTypeService service)
        {
            _service = service;
        }

        /// <summary>
        /// 查询单条记录
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet("{id}")]
        public async Task<ClaimTypeDto> GetAsync(Guid id)
        {
            return await _service.GetAsync(id);
        }

        /// <summary>
        /// 新增声明类型
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Guid?> InsertAsync(ClaimTypeDto dto)
        {
            return await _service.InsertAsync(dto);
        }

        /// <summary>
        /// 更新声明类型
        /// </summary>
        /// <param name="settingDto"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<bool> UpdateAsync(ClaimTypeDto dto)
        {
            return await _service.UpdateAsync(dto);
        }

        /// <summary>
        /// 删除声明类型
        /// </summary>
        /// <param name="settingDto"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<bool> DeleteAsync(ClaimTypeDto dto)
        {
            return await _service.DeleteAsync(dto);
        }

        /// <summary>
        /// 查询列表
        /// </summary>
        /// <param name="settingDto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PagedList<ClaimTypeDto>> GetPagedListAsync(ClaimTypeModel model)
        {
            return await _service.GetPagedListAsync(model);
        }

        /// <summary>
        /// 查询所有记录
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IEnumerable<ClaimTypeDto>> GetAllAsync()
        {
            return await _service.GetAllAsync();
        }
    }
}
